export default {
    namespaced: true,
    state: {
        //歌单分类
        showList: localStorage.getItem('showList') ? JSON.parse(localStorage.getItem('showList')) : ["网友精选", "推荐歌单", "精品歌单", "排行榜", "..."],
        //用户私人歌单
        userPrivatePlayList: sessionStorage.getItem('userPrivatePlayList') ? JSON.parse(sessionStorage.getItem('userPrivatePlayList')) : [],
        //用户登录状态
        loginStatus: sessionStorage.getItem('loginStatus') ? (sessionStorage.getItem('loginStatus')) : "false",
        //用户id
        userId: sessionStorage.getItem("userId") ? sessionStorage.getItem("userId") : "",
        //是否签到
        isSign: sessionStorage.getItem('isSign') ? sessionStorage.getItem('isSign') : false
    },
    mutations: {
        // 保歌单分类信息
        SAVE_SHOWLIST(state, showList) {
            state.showList = showList
        },
        //保存用户私人歌单
        SAVE_USERPRIVATEPLAYLIST(state, userPrivatePlayList) {
            state.userPrivatePlayList = userPrivatePlayList
        },
        //保存登录状态
        SAVE_LOGINSTATUS(state, loginStatus) {
            state.loginStatus = loginStatus
        },
        //保存用户id
        SAVE_USERID(state, userId) {
            state.userId = userId
        },
        //保存签到状态
        SAVE_ISSIGN(state, isSign) {
            state.isSign = isSign
        }
    },
    actions: {
        // 保歌单分类信息
        saveShowList({
            commit
        }, payload) {
            commit('SAVE_SHOWLIST', payload)
        },
        //保存用户私人歌单
        savePrivatePlayList({
            commit
        }, payload) {
            commit('SAVE_USERPRIVATEPLAYLIST', payload)
        },
        //保存用户登录状态
        saveLoginStatus({
            commit
        }, payload) {
            commit('SAVE_LOGINSTATUS', payload)
        },
        //保存用户id
        saveUserId({
            commit
        }, payload) {
            commit('SAVE_USERID', payload)
        },
        //保存签到信息
        saveIsSign({
            commit
        }, payload) {
            commit('SAVE_ISSIGN', payload)
        }
    },
    getters: {
        // 歌单分类信息
        showList: state => {
            return state.showList
        },
        //保存用户私人歌单
        userPrivatePlayList: state => {
            return state.userPrivatePlayList
        },
        //保存用户登录状态
        loginStatus: state => {
            return state.loginStatus
        },
        //保存用户id
        userId: state => {
            return state.userId
        },
        isSign: state => {
            return state.isSign
        }
    }
}